package vj.graph;

public class WtEdge implements Comparable<WtEdge>{
	
	public int u,v,wt;
	
	public WtEdge(int u, int v, int wt) {
		this.u = u;
		this.v = v;
		this.wt = wt;
	}
	
	@Override
	public int compareTo(WtEdge e1) {
		if(this.u != e1.u || this.v != e1.v)
			throw new IllegalArgumentException("Cannot compare edges between two different vertices");
		return 0;
	}
	
	@Override
	public boolean equals(Object obj) {
		if(obj instanceof WtEdge) {
			WtEdge e1 = (WtEdge) obj;
			if(this.u == e1.u && this.v == e1.v && this.wt == e1.wt)
				return true;
		}
		return false;
	}
	
	@Override
	public int hashCode() {
		return u * v * wt;
	}
	
	@Override
	public String toString() {
		String s = u + "--(" + wt + ")--" + v;
		return s;
	}
}
